package com.zyf.springcloud.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zyf.springcloud.dao.RoleUserDao;
import com.zyf.springcloud.model.RoleUser;
import com.zyf.springcloud.service.RoleUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoleUserServiceImpl extends ServiceImpl<RoleUserDao, RoleUser> implements RoleUserService {
    @Autowired
    RoleUserDao roleUserDao;
    public int selectRoleIdByUserId(Long id){
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",id);
        RoleUser roleUser = roleUserDao.selectOne(queryWrapper);
        if (roleUser==null){
            return 0;
        }
        return roleUser.getRoleId();
    }
}
